GBML manual / Input

btn_held

True this frame if button b is held down. Add a player number from 1 to 4 to ask another controller: btn_held(BTN_A, 2). Without one it is player 1.

Syntax

btn_held(b, player = 1) -> bool

Arguments

NameType
bbutton
playerint (can be left out; then it is 1)

Returns

bool

Description

True this frame if a given button is held down.

True on every frame a button is being held, from the frame it goes down through every frame afterward until it is released - the usual check for something that should keep happening while a button is down, like walking.

Another player

Write a player number from 1 to 4 after the button to ask that player's controller: btn_held(BTN_A, 2). Leave it out and it is player 1, the same as writing 1. The number has to be written out in the call (not kept in a variable), and a console that has fewer controllers than that tells you so when you check the game: the Game Boy Advance has one, so only player 1 works there.

Example

if (btn_held(BTN_A)) {
    var pressed_a = true;
}

Checks the A button's held state every frame and records it in a project-defined pressed_a variable.

On the GBA

The Game Boy Advance has one controller, so only player 1 can be asked here (written out or left out, it is the same call).

See also: btn_pressedbtn_releasedBTN_A